/**
* @author:kellen
* @contact:xiekellen@hotmail.com
* @company:achivo-gz
* @created on:
* @modified on:
*/

package com.sasis.dao.ibatis;

import java.util.List;

import com.sasis.dao.ibatis.BaseDaoiBATIS;
import com.sasis.model.VipServiceSendcar;
import com.sasis.dao.VipServiceSendcarDao;

import org.springframework.orm.ObjectRetrievalFailureException;

public class VipServiceSendcarDaoiBatis extends BaseDaoiBATIS implements VipServiceSendcarDao {

    /**
     * @see com.sasis.dao.VipServiceSendcarDao#getVipServiceSendcars(com.sasis.model.VipServiceSendcar)
     */
    public List getVipServiceSendcars(final VipServiceSendcar vipServiceSendcar) {
          return getSqlMapClientTemplate().queryForList("getVipServiceSendcars", vipServiceSendcar);
    }

    /**
     * @see com.sasis.dao.VipServiceSendcarDao#getVipServiceSendcar(Integer id)
     */
    public VipServiceSendcar getVipServiceSendcar(Integer id) {
        VipServiceSendcar vipServiceSendcar = (VipServiceSendcar) getSqlMapClientTemplate().queryForObject("getVipServiceSendcar", id);

//        if (vipServiceSendcar == null) {
//            throw new ObjectRetrievalFailureException(VipServiceSendcar.class, id);
//        }

        return vipServiceSendcar; 
    }

    /**
     * @see com.sasis.dao.VipServiceSendcarDao#saveVipServiceSendcar(VipServiceSendcar vipServiceSendcar)
     */    
    public int saveVipServiceSendcar(final VipServiceSendcar vipServiceSendcar) {
        Integer id = vipServiceSendcar.getId();
        // check for new record
        if (id == null) {
            id = (Integer) getSqlMapClientTemplate().insert("addVipServiceSendcar", vipServiceSendcar);
        } else {
            getSqlMapClientTemplate().update("updateVipServiceSendcar", vipServiceSendcar);
        }
        if( id == null ) {
            throw new ObjectRetrievalFailureException(VipServiceSendcar.class, id);
        }
        return id.intValue();
    }

    /**
     * @see com.sasis.dao.VipServiceSendcarDao#removeVipServiceSendcar(Integer id)
     */
    public void removeVipServiceSendcar(VipServiceSendcar vipServiceSendcar) {
        getSqlMapClientTemplate().update("deleteVipServiceSendcar",  vipServiceSendcar);
    }
}
